﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TiffSplit
{
    public partial class PageSelection : Form
    {
        public int PageTo { private set; get; }
        public int PageFrom { private set; get; }
        public bool OverwriteFiles { private set; get; }

        public PageSelection(int lastPage)
        {
            InitializeComponent();

            label_ValidRange.Text = "Valid Range: 1 - " + lastPage.ToString();
            numericUpDown_from.Minimum = 1;
            numericUpDown_from.Maximum = (decimal)lastPage;
            numericUpDown_from.Value = 1;
            numericUpDown_to.Minimum = 1;
            numericUpDown_to.Maximum = (decimal)lastPage;
            numericUpDown_to.Value = (decimal)lastPage;
        }

        private void button_cont_Click(object sender, EventArgs e)
        {
            if (numericUpDown_to.Value < numericUpDown_from.Value)
            {
                MessageBox.Show("Page range values invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            PageFrom = (int)numericUpDown_from.Value;
            PageTo = (int)numericUpDown_to.Value;
            OverwriteFiles = checkBox_overwrite.Checked;

            Close();
        }
    }
}
